﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Fayshine.VA.RIAService.Web;
using Fayshine.VA.Helpers;

namespace Fayshine.VA.Views.SysConfig
{
    public partial class POSView : ChildWindow
    {

        public pos EditPos
        {
            get;
            set;
        }

        public POSView(string title, pos editingPos)
        {
            InitializeComponent();

            this.Title = title;
            if (editingPos != null)
            {
                this.EditPos = editingPos;
            }
            else
            {
                this.EditPos = new pos() { TradeDate = DateTime.Now, TradeTime = DateTime.Now.TimeOfDay, TradeCount = 0, TradeMoney = 0.00, GoldCount = 0, GoldMoney = 0, SilerCount = 0, SilverMoey = 0 };
                this.timePicker.Value = DateTime.Now;
              
            }

            this.DataContext = this.EditPos;

        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.timePicker.Value != null)
            {
                this.EditPos.TradeTime = this.timePicker.Value.Value.TimeOfDay;
            }

            if (this.EditPos.TradeDate == null || this.EditPos.TradeTime == null)
            {
                MessageBox.Show("交易日期或者时间不能为空！");
                return;
            }

            if (this.EditPos.AreaID <= 0)
            {
                MessageBox.Show("请选择店铺！");
                return;
            }

            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }


}

